package goals;

import world.Person;
import world.PhysicalObject;
import control.GUI.Output;

public class GoalPickUp extends Goal {

	private PhysicalObject target;

	public PhysicalObject getTarget() {
		return target;
	}
	public GoalPickUp(Person self, PhysicalObject target) {
		super(self, 20);
		this.target = target;
	}

	@Override
	public boolean act(Output out) {
		moveTowards(target);
		if (self.getPosition().distance(target.getPosition()) < 1e-3) {
			target.setOwner(self);
			self.addToInventory(target);
			out.push(self.getName() + " picks up " + target.getName() + "\n");
			return true;
		}
		return false;
	}

	@Override
	public int getReevaluationTimeSpan() {
		return 10;
	}

	@Override
	public String toString() {
		return "pick up " + target.getName();
	}

}
